package com.ruoyi.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.admin.domain.CorpCompanyUsers;
import com.ruoyi.admin.service.ICorpCompanyUsersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户列Controller
 * 
 * @author Jimmy
 * @date 2022-08-04
 */
@RestController
@RequestMapping("/admin/corp_company_users")
public class CorpCompanyUsersController extends BaseController
{
    @Autowired
    private ICorpCompanyUsersService corpCompanyUsersService;

    /**
     * 查询用户列列表
     */
    @PreAuthorize("@ss.hasPermi('admin:corp_company_users:list')")
    @GetMapping("/list")
    public TableDataInfo list(CorpCompanyUsers corpCompanyUsers)
    {
        startPage();
        List<CorpCompanyUsers> list = corpCompanyUsersService.selectCorpCompanyUsersList(corpCompanyUsers);
        return getDataTable(list);
    }

    /**
     * 导出用户列列表
     */
    @PreAuthorize("@ss.hasPermi('admin:corp_company_users:export')")
    @Log(title = "用户列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CorpCompanyUsers corpCompanyUsers)
    {
        List<CorpCompanyUsers> list = corpCompanyUsersService.selectCorpCompanyUsersList(corpCompanyUsers);
        ExcelUtil<CorpCompanyUsers> util = new ExcelUtil<CorpCompanyUsers>(CorpCompanyUsers.class);
        util.exportExcel(response, list, "用户列数据");
    }

    /**
     * 获取用户列详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:corp_company_users:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(corpCompanyUsersService.selectCorpCompanyUsersById(id));
    }

    /**
     * 新增用户列
     */
    @PreAuthorize("@ss.hasPermi('admin:corp_company_users:add')")
    @Log(title = "用户列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CorpCompanyUsers corpCompanyUsers)
    {
        return toAjax(corpCompanyUsersService.insertCorpCompanyUsers(corpCompanyUsers));
    }

    /**
     * 修改用户列
     */
    @PreAuthorize("@ss.hasPermi('admin:corp_company_users:edit')")
    @Log(title = "用户列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CorpCompanyUsers corpCompanyUsers)
    {
        return toAjax(corpCompanyUsersService.updateCorpCompanyUsers(corpCompanyUsers));
    }

    /**
     * 删除用户列
     */
    @PreAuthorize("@ss.hasPermi('admin:corp_company_users:remove')")
    @Log(title = "用户列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(corpCompanyUsersService.deleteCorpCompanyUsersByIds(ids));
    }
}
